/*
 * 项目名称:    wms-server-jeecg
 * 创建人员:    hansen
 * 创建时间:    2023-10-25
 */
package org.jeecg.modules.dock.entity.mes.request;

import cn.hutool.core.collection.CollectionUtil;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

/**
 * MES-WMS发送纵剪消耗纸筒
 *
 * @author hansen
 * @version 1.0.0
 * @date 2023-10-25 09:15:27
 */
@Data
@ToString(callSuper = true)
public class RepertoryRequestParam  {
    /**
     * 1:按仓库查 (返回查询仓库的所有批次信息) (批次号、订单号为空)
     * 2:按批次号查(返回查询的批次信息)(仓库编码、订单号为空)
     * 3：查询辅材库存(待定)
     */
    @NotNull(message = "类型不能为空")
    @ApiModelProperty("类型")
    private Integer type;

    @NotNull
    @ApiModelProperty("明细")
    private List<Detail> detail;

    @JsonIgnore
    private List<String > condition;

    public List<String> getCondition() {
        condition = new ArrayList<>();
        if (CollectionUtil.isNotEmpty(detail)){
            for (Detail d : detail) {
                if (type == 1){
                    condition.add(d.warehouseCode);
                }else if (type == 2){
                    condition.add(d.batchId);
                }
            }
        }
        return condition;
    }

    @Data
    public static class Detail implements Serializable {

        @ApiModelProperty("仓库编码")
        private String warehouseCode;

        @ApiModelProperty("批次号，长度10位")
        private String batchId;

        @ApiModelProperty("生产订单号")
        private String orderCode;
    }
}
